/*登录表单的验证*/
$("#login-modal").bootstrapValidator({
	message:"这是无效的数据域",
	feedbackIcons: {/*input状态样式图片*/
        valid: 'glyphicon glyphicon-ok',
        invalid: 'glyphicon glyphicon-remove',
        validating: 'glyphicon glyphicon-refresh'
    },
    fields:{
    	username:{
    		message:"无效",
    		validators:{
    			notEmpty:{
    				message:"用户名不可为空"
    			},
    			stringLength: {
                min: 6,
                max: 30,
                message: '用户名长度必须在6到30之间'
                },
    		}
    	},
    	password: {
            message:'密码无效',
            validators: {
                notEmpty: {
                    message: '密码不能为空'
                },
                stringLength: {
                    min: 6,
                    max: 20,
                    message: '密码不小于6位'
                },
            }
        },
    }
});

/*登录表单验证*/
$("#register-modal").bootstrapValidator({
	message:"这是无效的数据域",
	feedbackIcons: {/*input状态样式图片*/
        valid: 'glyphicon glyphicon-ok',
        invalid: 'glyphicon glyphicon-remove',
        validating: 'glyphicon glyphicon-refresh'
    },
    fields:{
    	username:{
    		message:"无效",
    		validators:{
    			notEmpty:{
    				message:"用户名不可为空"
    			},
    			stringLength: {
                min: 6,
                max: 10,
                message: '用户名长度必须在6到10之间'
                },
    		}
    	},
    	password: {
            message:'密码无效',
            validators: {
                notEmpty: {
                    message: '密码不能为空'
                },
                stringLength: {
                    min: 6,
                    max: 20,
                    message: '密码不小于6位'
                },
                identical: {//相同
                    field: 'password', //需要进行比较的input name值
                    message: '两次密码不一致'
                },
                different: {//不能和用户名相同
                    field: 'username',//需要进行比较的input name值
                    message: '不能和用户名相同'
                },
            }
        },
	    repassword: {
	        message: '密码无效',
	        validators: {
	                notEmpty: {
	           		message: '用户名不能为空'
	            },
	            	stringLength: {
	            	min: 6,
	            	max: 20,
	           		message: '密码长度必须在6到20之间'
	            },
	        identical: {//相同
	                field: 'password',
	                message: '两次密码不一致'
	            },
	        different: {//不能和用户名相同
	                field: 'username',
	                message: '不能和用户名相同'
	            },
	      
	        }
	    },
    }
});





/*获取表格的内容放进表单里*/
$("#eqid").val($(".eq-table table td:eq(0)").text());
$("#eqname").val($(".eq-table table td:eq(1)").text());


/*租借表单验证*/
$("#eq-rent-modal").bootstrapValidator({
	message:"这是无效的数据域",
	feedbackIcons: {/*input状态样式图片*/
        valid: 'glyphicon glyphicon-ok',
        invalid: 'glyphicon glyphicon-remove',
        validating: 'glyphicon glyphicon-refresh'
    },
    fields:{
    	eqid:{
    		message:"无效",
    		validators:{
    			notEmpty:{
    				message:"编号不可为空"
    			},
    			stringLength: {
                min: 3,
                max: 3,
                message: '编号为3位数'
                },
    		}
    	},
    	eqname: {
            message:'无效',
            validators: {
                notEmpty: {
                    message: '器材名不可为空'
                },
            }
        },
        eqnum: {
            message:'密码无效',
            validators: {
                notEmpty: {
                    message: '数量不能为空'
                },
                regexp: {
                	regexp: /^[0-9]+(.[0-9]{1,3})?$/,
                    message: '必须是数字'
                },
            }
        },
        equsername: {
            message:'无效',
            validators: {
                notEmpty: {
                    message: '姓名不能为空'
                },
                stringLength: {
                min: 3,
                max: 30,
                message: '用户名长度必须在6到30之间'
                },
            }
        },
        eqcontact: {
            message:'无效',
            validators: {
                notEmpty: {
                    message: '联系方式不能为空'
                },
                stringLength: {
                    min: 11,
                    max: 11,
                    message: '请输入正确的手机号码'
                },
            }
        },
    }
});